package com.erp.app.common.attachment.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.erp.app.common.attachment.beans.AttachmentVo;
import com.erp.app.common.attachment.pk.AttachmentPk;
import com.erp.framework.exceptions.FindRecordException;
import com.erp.framework.model.dao.SimpleSearchMaintStyleDao;
import com.erp.framework.model.vo.ChildList;
import com.erp.framework.model.vo.SimpleBaseVo;
import com.erp.framework.types.CustomBigInteger;
import com.erp.framework.types.CustomBlob;
import com.erp.framework.types.CustomSqlDate;

public class AttachmentCommonDao extends SimpleSearchMaintStyleDao{

	protected String sqlFind() {
		String sql = "SELECT COMPANY_CODE, LINE_NO, ATTACHMENT_DESC, CONTENT_TYPE, CREATE_USER, "
			+ "CREATE_DATE, UPDATE_USER, UPDATE_DATE, DC_IND, DC_DATE, ATTACHMENT, FILE_NAME "
			+ "FROM T_ATTACHMENT "
			+ "WHERE COMPANY_CODE=? AND LINE_NO=? "
			+ "ORDER BY COMPANY_CODE, LINE_NO";
		return sql;
	}

	protected void setValuesForFind(PreparedStatement pStmt, Object obj) throws SQLException {
		AttachmentPk pk = (AttachmentPk) obj;
		int i = 1;

		pStmt.setString(i++, pk.getCompanyCode());
		pStmt.setInt(i++, pk.getAttachmentAttachmentLineNo().intValue());
	}


    protected boolean isViewOnly() {
        return false;
    }

	protected SimpleBaseVo getResultSetValues(ResultSet rs) throws SQLException {
		AttachmentVo vo = new AttachmentVo();

		vo.setCompanyCode(rs.getString("COMPANY_CODE"));
		vo.setAttachmentAttachmentLineNo(CustomBigInteger.customize(rs.getBigDecimal("LINE_NO")));
		vo.setAttachmentDescription(rs.getString("ATTACHMENT_DESC"));
		vo.setAttachmentContentType(rs.getString("CONTENT_TYPE"));
		vo.setAttachmentDcInd(rs.getString("DC_IND"));
		vo.setAttachmentDcDate(CustomSqlDate.customize(rs.getDate("DC_DATE")));
		vo.setCreateUser(rs.getString("CREATE_USER"));
		vo.setCreateDate(rs.getTimestamp("CREATE_DATE"));
		vo.setUpdateUser(rs.getString("UPDATE_USER"));
		vo.setUpdateDate(rs.getTimestamp("UPDATE_DATE"));
		vo.setAttachment(CustomBlob.customize(rs.getBlob("ATTACHMENT")));
		vo.setAttachmentFileName(rs.getString("FILE_NAME"));

		return vo;
	}

	public ChildList selectByParent(SimpleBaseVo parent, Connection conn) throws FindRecordException {
		// TODO Auto-generated method stub
		return null;
	}

	protected void setValuesForDelete(PreparedStatement pStmt, Object obj) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	protected void setValuesForInsert(PreparedStatement pStmt, Object obj) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	protected void setValuesForList(PreparedStatement pStmt, Object obj) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	protected void setValuesForModify(PreparedStatement pStmt, Object obj) throws SQLException {
		// TODO Auto-generated method stub
		
	}

	protected String sqlDelete() {
		// TODO Auto-generated method stub
		return null;
	}

	protected String sqlInsert() {
		// TODO Auto-generated method stub
		return null;
	}

	protected String sqlList() {
		// TODO Auto-generated method stub
		return null;
	}

	protected String sqlUpdate() {
		// TODO Auto-generated method stub
		return null;
	}

}
